package wei.xinya.pattern.creational.Prototype;

public class UnderlinePen implements Product {
    private final char aChar;

    UnderlinePen(char aChar) {
        this.aChar = aChar;
    }

    @Override
    public void use(String s) {
        int length = s.getBytes().length;
        System.out.println("\""+s+"\"");
        for (int i = 0; i <length+2; i++) {
            System.out.print(aChar);

        }
        System.out.println();
    }

    @Override
    public Product creatClone() {
        Product p=null;
        try {
            p=(Product) clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return p;
    }
}
